<?php
/**
 * MongoDig
 *
 * @copyright  Copyright (c) 2010 lanyanguang (http://www.lanyg.com)
 * @license    GNU General Public License 2.0
 * @version    $Id$
 */

/** user逻辑操作 */

//插入一个投票
function vote_insert($vote)
{
	global $db;
	$collection = $db->vote;
	$collection->insert($vote);
}

//批量添加投票
function vote_insert_patch($votes)
{
	global $db;
	$collection = $db->vote;
	$collection->batchInsert($votes);
}

//删除一个投票
function vote_delete($filter)
{
	global $db;
	$collection = $db->vote;
	$collection->remove($filter);
}

//更新一个投票信息
function vote_update($filter,$vote)
{
	global $db;
	$collection = $db->vote;
	$collection->update($filter,$vote);
}

//查找一个投票信息
function vote_find_one($filter)
{
	global $db;
	$collection = $db->vote;
	return $vote = $collection->findOne($filter);
}

//查找投票信息
function vote_find($filter='')
{
	global $db;
	$collection = $db->vote;
	if(empty($filter)){
		return $vote = $collection->find();
	}else{
		return $vote = $collection->find($filter);
	}
}